﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Snowdreamist.Windows.Navigation.Primitives;

namespace Snowdreamist.Windows.Navigation
{
    public class NavigationJournalEntry
    {
        public NavigationJournalEntry(NavigationJournal journal, Uri uri, bool isSavedFrame, SessionFrame frame)
        {
            if (journal == null)
                throw new ArgumentNullException("journal");

            this.Journal = journal;
            this.Uri = uri;
            this.IsSavedFrame = isSavedFrame;
            this.Frame = frame;
            this.MetaJournal = new MetaJournal();
            this.MetaJournal.JournalChanged += new EventHandler<JournalChangedEventArgs<MetaJournalEntry>>(MetaJournal_JournalChanged);
        }

        public NavigationJournal Journal { get; private set; }

        public MetaJournal MetaJournal { get; private set; }

        /// <summary>
        /// Uri
        /// </summary>
        public Uri Uri { get; private set; }

        /// <summary>
        /// Is frame saved
        /// </summary>
        public bool IsSavedFrame { get; internal set; }

        /// <summary>
        /// session frame
        /// </summary>
        public SessionFrame Frame { get; internal set; }

        private void MetaJournal_JournalChanged(object sender, JournalChangedEventArgs<MetaJournalEntry> e)
        {
            this.Journal.OnMetaJournalChanged(e.Current);
        }
    }
}